// 接收两个对象，判断他们是否全等
function equals (x, y) {
  const f1 = x instanceof Object
  const f2 = y instanceof Object
  if (!f1 || !f2) {
    return x === y
  }
  if (Object.keys(x).length !== Object.keys(y).length) {
    return false
  }
  const newX = Object.keys(x)
  for (let p in newX) {
    p = newX[p]
    const a = x[p] instanceof Object
    const b = y[p] instanceof Object
    if (a && b) {
      equals(x[p], y[p])
    } else if (x[p] !== y[p]) {
      return false
    }
  }
  return true
}

export default equals
